package aliyun

import (
	"gitee.com/amoyx/cloud-provider/pkg/cloud/aliyun/compute"
	"gitee.com/amoyx/cloud-provider/pkg/cloud/aliyun/network"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
)

type AliCloudInterface interface {
	Computes() compute.CloudComputeInterface
	Networks() network.CloudNetworkInterface
}

type AliCloudClient struct {
	secretId  string
	secretKey string
	config    *openapi.Config
}

func NewAliCloudClient(secretId string, secretKey string) AliCloudInterface {
	config := &openapi.Config{
		AccessKeyId:     &secretId,
		AccessKeySecret: &secretKey,
	}
	return &AliCloudClient{
		config:    config,
		secretId:  secretId,
		secretKey: secretKey,
	}
}

func (a *AliCloudClient) Computes() compute.CloudComputeInterface {
	return compute.NewCompute(a.Config())
}

func (a *AliCloudClient) Networks() network.CloudNetworkInterface {
	return network.NewNetwork(a.Config())
}

func (a *AliCloudClient) SecretId() string {
	return a.secretId
}

func (a *AliCloudClient) SecretKey() string {
	return a.secretKey
}

func (a *AliCloudClient) Config() *openapi.Config {
	return a.config
}
